#include<bits/stdc++.h>
using namespace std;
namespace IO{
#define isDigit(x) ((x)>='0'&&(x)<='9')
template<typename T>
    inline void read(T&x){
        x=0;
        register char c=getchar();
        register bool fu=0;
        while(!isDigit(c)&&c!='-')
                c=getchar();
        if(c=='-')
            fu=1,c=getchar();
        while(isDigit(c))
            x=(x<<1)+(x<<3)+(c^48),c=getchar();
        if(fu==1)
            x=(~(x-1));
    }
    template<typename T>
    inline void _print(T x){
        if(x>9)
            _print(x/10);
        putchar((x%10)|48);
    }
    template<typename T>
    inline void print(T x){
        if(x<0)
            putchar('-'),
            _print((~(x-1)));
        else _print(x);
    }
}
using namespace IO;
struct Car{
    int d,v,a;
    Car():d(0),v(0),a(0){}
};
bitset<1000005>needed;
set<int>p;//dis of derectors . rt
vector<Car>c;
int n,m,q,L,V;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    read(q);
    while(q--){
        read(n);
        c=vector<Car>(n+1);
        read(m);
        p.clear();
        read(L);
        read(V);
        bool zero=1;//Whether all "a" are zero . Point 3~4 .
        int lpos=9999999,rpos=-9999999;//Detectors' most L/R pos .
        for(int i=1;i<=n;++i){
            read(c[i].d);
            read(c[i].v);
            read(c[i].a);
            if(c[i].a!=0)
                zero=0;
        }
        int x;
        for(int i=1;i<=n;++i){
            read(x);
            lpos=min(lpos,x);
            rpos=max(rpos,x);
            p.insert(x);
        }
        int tot=0;
        if(zero){
            for(auto t:c)
                tot+=(t.v>V);
            print(tot);
            printf(" 1");
            return 0;
        }
        for(int i=1;i<=n;++i){
            if(c[i].a<0)continue;
            double dd=c[i].d,dv=c[i].v,da=c[i].a;
            double Vpos=dd-(dv*dv-V*V)/(2.0*da);
            if(Vpos<=rpos&&Vpos>=lpos){
                ++tot;
                needed[*p.lower_bound(Vpos)]=1;
            }
        }
        print(tot);
        putchar(' ');
        print(needed.count());
        putchar('\n');
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
